home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / Systemmonitors / Snoopy / Sources / parse.asm < prev    next >
Assembly Source File  |  1996-09-26  |  45KB  |  1,814 lines

  1.  
  2.  
  3.         incpath    include:
  4.         maclib    sm.mac
  5.         macfile    macro.i
  6.         macfile    snoopy.i
  7.         macfile    macros/parse
  8.         macfile    extern/main
  9.         macfile    extern/misc
  10.  
  11.         section    main,code
  12.  
  13. ERROR_NONE            equ    0
  14. ERROR_INVALID_LINE        equ    1
  15. ERROR_INTERNAL            equ    2
  16. ERROR_NOT_ENOUGH_MEMORY        equ    3
  17. ERROR_ABORT            equ    4
  18.  
  19. ASSUME_LONG    equ    0
  20. ASSUME_WORD    equ    1
  21. ASSUME_BYTE    equ    2
  22.     
  23. ***********************************************************************************
  24. ;--------------    parse a scriptfile with a given name. Note that this parser
  25. ;--------------    is re-entrant, which means that includes are just normal scriptfiles
  26. ;--------------    like the main scriptfile.
  27. ;--------------    
  28. ;--------------    => a0: APTR filename of scriptfile
  29. ;--------------    <= d0: BOOL success
  30.         STRUCTURE psfStack,0
  31.         APTR    psf_Filename
  32.         APTR    psf_FileHandle
  33.         LONG    psf_Line
  34.         LABEL    psf_SIZEOF
  35.  
  36.         ENTRY    ParseScriptFile,d1-d7/a0-a6,psf_SIZEOF,a5
  37.         move.l    a0,(psf_Filename,a5)
  38.         clr.b    (includeLevel)
  39.         clr.l    (flagSkipSimilar)
  40.         clr.l    (priority)
  41.         clr.b    (outputMemory)
  42.         clr.l    (timeout)
  43.         clr.l    (structureOffset)
  44.         move.b    #ASSUME_WORD,(assume)
  45.         move.l    (argNoSegTracker),d0
  46.         not.l    d0
  47.         move.l    d0,(flagSegTracker)
  48.  
  49. ;--------------    copy command line incdir
  50.         tst.l    (argIncdir)
  51.         beq.b    .NOINCDIR
  52.         lea    (incdirBuffer),a1
  53.         movea.l    (argIncdir),a0
  54.         move.w    #MAX_INCDIRNAME-1,d0
  55.         STRCPY    a0,a1
  56. .NOINCDIR    
  57. ;--------------    open file
  58.         move.l    (psf_Filename,a5),d1
  59.         move.l    d1,(outputArgs)
  60.         move.l    #MODE_OLDFILE,d2
  61.         CALL    Open,dosBase
  62.         move.l    d0,(psf_FileHandle,a5)
  63.         beq.b    .NoFile
  64.  
  65. ;--------------    read all lines one-by-one
  66. .LOOP        move.l    (psf_FileHandle,a5),d1
  67.         move.l    #inputMemory,d2
  68.         move.l    #MAX_INPUT,d3
  69.         CALL    FGets
  70.         tst.l    d0
  71.         beq.b    .DONE
  72.         addq.l    #1,(psf_Line,a5)
  73.         move.l    (psf_Line,a5),(currentLine)
  74.         bsr.b    ProcessInput
  75.         tst.l    d0
  76.         bne.b    .FAIL
  77.         bra.b    .LOOP
  78.  
  79. ;--------------    FGets() returned NULL; so we have to check if it was EOF or an error
  80. .DONE        CALL    IoErr
  81.         move.l    d0,d1
  82.         beq.b    .ReallyDone
  83.  
  84. ;--------------    it WAS an error, so show it and exit
  85.         jsr    ShowDosError
  86. .FAIL        move.l    (psf_FileHandle,a5),d1
  87.         CALL    Close
  88.         moveq    #ERROR_INVALID_LINE,d0
  89.         bra.b    ParseScriptFile_done
  90.  
  91. ;--------------    return to sender
  92. .ReallyDone    move.l    (psf_FileHandle,a5),d1
  93.         CALL    Close
  94.         moveq    #ERROR_NONE,d0
  95.         bra.b    ParseScriptFile_done
  96.  
  97. ;--------------    some error message
  98. .NoFile        lea    (openfileErr,pc),a0
  99.         jsr    ShowErrorMessage
  100.         moveq    #ERROR_INTERNAL,d0
  101.         DONE    ParseScriptFile
  102.  
  103. ***********************************************************************************
  104. ;--------------    process current input data line (in 'input' buffer)
  105. ;--------------    
  106. ;--------------    <= d0: BOOL success
  107. ;--------------    
  108.         ENTRY    ProcessInput,d1-d7/a0-a6
  109.         bsr    PrepareInput
  110.         tst.b    (input)
  111.         beq    .DONE
  112.  
  113. ;--------------    see if it is one of the codewords we need 
  114.         lea    (KeywordTable),a0
  115. .CodewordLoop    tst.l    (a0)
  116.         beq.b    .InvalidLine
  117.  
  118. ;--------------    compare codeword and inputline
  119.         move.l    (a0),a1
  120.         lea    (input),a2
  121. .STRICMP    move.b    (a1)+,d0
  122.         beq.b    .Found
  123.         move.b    (a2)+,d1
  124.         UCASE    d1
  125.         cmp.b    d1,d0
  126.         beq.b    .STRICMP
  127.  
  128. .NotFound    addq.l    #8,a0
  129.         bra.b    .CodewordLoop        
  130.  
  131. ;--------------    codeword found -> call function !
  132. .Found        tst.b    (a2)
  133.         beq.b    .FOUND
  134.         cmpi.b    #"=",(a2)+
  135.         bne.b    .NotFound
  136. .FOUND        tst.l    (4,a0)
  137.         beq.b    .DONE
  138.         move.l    (4,a0),a1
  139.         movea.l    a2,a0        ; a0 = start of current line
  140.         jsr    a1        ; a1 = code for handler function
  141.         tst.l    d0
  142.         beq.b    ProcessInput_done
  143.         cmpi.l    #ERROR_NOT_ENOUGH_MEMORY,d0
  144.         beq.b    .NOMEMORY
  145.  
  146. ;--------------    invalid input line
  147.         cmpi.l    #ERROR_INVALID_LINE,d0
  148.         bne.b    ProcessInput_done
  149. .InvalidLine    lea    (invalidlineErr,pc),a0
  150.         bsr    ParserError
  151.         bra.b    ProcessInput_done
  152.  
  153. ;--------------    not enough memory, display alert (because it doesn't eat up memory)
  154. .NOMEMORY    move.l    #RECOVERY_ALERT,d0    ; AlertNumber
  155.         lea    (memoryError,pc),a0    ; String
  156.         moveq    #50,d1            ; Height
  157.         CALL    DisplayAlert,intBase
  158.         moveq    #ERROR_NOT_ENOUGH_MEMORY,d0
  159.         bne.b    ProcessInput_done
  160.  
  161. .DONE        moveq    #ERROR_NONE,d0
  162.         DONE    ProcessInput
  163.  
  164. ***********************************************************************************
  165. ;--------------    define a new library base
  166. ;--------------    
  167. ;--------------    => a0: APTR current string position
  168.  
  169.         ENTRY    SetBase,d1-d7/a0-a6
  170.  
  171. ;--------------    create new list entry
  172.         move.l    #sbase_SIZEOF,d0
  173.         lea    (bases),a1
  174.         bsr    CreateEntry
  175.         tst.l    d0
  176.         beq    .NoMemory
  177.  
  178. ;--------------    copy base
  179.         lea    (sbase_Name,a5),a1
  180.         moveq    #MAX_BASENAME-2,d1
  181. .CopyBaseName    move.b    (a0)+,d0
  182.         beq    .FAILURE
  183.         cmpi.b    #",",d0
  184.         beq.b    .NameFound
  185.         UCASE    d0
  186.         move.b    d0,(a1)+
  187.         dbra    d1,.CopyBaseName
  188.         bra    .BaseTooLong
  189. .NameFound    clr.b    (a1)+
  190.         move.l    a0,d7        ; d7 = library name
  191.  
  192. .FindEnd    move.b    (a0)+,d0
  193.         beq.b    .EndFound
  194.  
  195. ;--------------    another comma indicates the user wants to give a version description
  196.         cmpi.b    #",",d0
  197.         bne.b    .FindEnd
  198. .Version    clr.b    (-1,a0)
  199.         moveq    #STVFORMAT_DEC,d0
  200.         jsr    StringToValue
  201.         move.l    d0,d6
  202.         bra.b    .GoOn
  203.  
  204. ;--------------    we have to remove trailing whitespaces because the library name
  205. ;--------------    is to be directly transfered to OpenLibrary() which otherwise
  206. ;--------------    could fail
  207. .EndFound    subq.l    #1,a0
  208. .WhileIsWhite    cmpa.l    d7,a0
  209.         beq.b    .WhiteIsDone
  210.         move.b    -(a0),d0
  211.         cmpi.b    #" ",d0
  212.         beq.b    .WhileIsWhite
  213.         cmpi.b    #"    ",d0
  214.         beq.b    .WhileIsWhite
  215. .WhiteIsDone    clr.b    (1,a0)
  216.  
  217. ;--------------    now try to open the library
  218. .GoOn        movea.l    d7,a1
  219.         move.l    d6,d0
  220.         CALL    OpenLibrary,<(execBase).w>
  221.         move.l    d0,(sbase_Library,a5)
  222.         beq.b    .CannotOpenLib
  223. .DONE        moveq    #ERROR_NONE,d0
  224.         bra.b    SetBase_done
  225.  
  226. ;--------------    base name exceeds MAX_BASENAME
  227. .BaseTooLong    lea    (basesizeErr,pc),a0
  228.         bra.b    .SHOWERROR
  229.  
  230. ;--------------    unable to OpenLibrary()
  231. .CannotOpenLib    lea    (openlibErr,pc),a0
  232.         move.l    d7,outputArgs+4
  233. .SHOWERROR    bsr    ParserError
  234.         bra.b    SetBase_done
  235.  
  236. .NoMemory    moveq    #ERROR_NOT_ENOUGH_MEMORY,d0
  237.         bra.b    SetBase_done
  238.  
  239. .FAILURE    moveq    #ERROR_INVALID_LINE,d0
  240.         DONE    SetBase
  241.  
  242. ***********************************************************************************
  243. ;--------------    define a new resource base
  244. ;--------------    
  245. ;--------------    => a0: APTR current string position
  246.  
  247.         ENTRY    SetResource,d1-d7/a0-a6
  248.  
  249. ;--------------    create new list entry
  250.         move.l    #sbase_SIZEOF,d0
  251.         lea    (resources),a1
  252.         bsr    CreateEntry
  253.         tst.l    d0
  254.         beq    .NoMemory
  255.  
  256. ;--------------    copy base
  257.         lea    (sbase_Name,a5),a1
  258.         moveq    #MAX_BASENAME-2,d1
  259. .CopyBaseName    move.b    (a0)+,d0
  260.         beq    .FAILURE
  261.         cmpi.b    #",",d0
  262.         beq.b    .NameFound
  263.         UCASE    d0
  264.         move.b    d0,(a1)+
  265.         dbra    d1,.CopyBaseName
  266.         bra    .BaseTooLong
  267. .NameFound    clr.b    (a1)+
  268.         move.l    a0,d7        ; d7 = library name
  269. .FindEnd    subq.l    #1,a0
  270.  
  271. ;--------------    we have to remove trailing whitespaces because the library name
  272. ;--------------    is to be directly transfered to OpenResource() which otherwise
  273. ;--------------    could fail
  274. .WhileIsWhite    cmpa.l    d7,a0
  275.         beq.b    .WhiteIsDone
  276.         move.b    -(a0),d0
  277.         cmpi.b    #" ",d0
  278.         beq.b    .WhileIsWhite
  279.         cmpi.b    #"    ",d0
  280.         beq.b    .WhileIsWhite
  281. .WhiteIsDone    clr.b    (1,a0)
  282.  
  283. ;--------------    now try to open the library
  284. .GoOn        movea.l    d7,a1
  285.         CALL    OpenResource,<(execBase).w>
  286.         move.l    d0,(sbase_Library,a5)
  287.         beq.b    .CannotOpenRes
  288. .DONE        moveq    #ERROR_NONE,d0
  289.         bra.b    SetBase_done
  290.  
  291. ;--------------    base name exceeds MAX_BASENAME
  292. .BaseTooLong    lea    (basesizeErr,pc),a0
  293.         bra.b    .SHOWERROR
  294.  
  295. ;--------------    unable to OpenLibrary()
  296. .CannotOpenRes    lea    (openresErr,pc),a0
  297.         move.l    d7,outputArgs+4
  298. .SHOWERROR    bsr    ParserError
  299.         bra.b    SetResource_done
  300.  
  301. .NoMemory    moveq    #ERROR_NOT_ENOUGH_MEMORY,d0
  302.         bra.b    SetResource_done
  303.  
  304. .FAILURE    moveq    #ERROR_INVALID_LINE,d0
  305.         DONE    SetResource
  306.  
  307. ***********************************************************************************
  308. ;--------------    define a new library base
  309. ;--------------    
  310. ;--------------    => a0: APTR current string position
  311.  
  312.         ENTRY    SetDevice,d1-d7/a0-a6
  313.  
  314. ;--------------    create new list entry
  315.         move.l    #sdevbase_SIZEOF,d0
  316.         lea    (deviceBases),a1
  317.         bsr    CreateEntry
  318.         tst.l    d0
  319.         beq    .NoMemory
  320.  
  321. ;--------------    setup list header
  322.         lea    (sdevbase_Patches,a5),a1
  323.         NEWLIST    a1
  324.  
  325. ;--------------    creatup message port **NOT SUPPORTED YET**
  326.         ;push    a0
  327.         ;CALL    CreateMsgPort,<(execBase).w>
  328.         ;pop    a0
  329.         ;move.l    d0,(sdevbase_MsgPort,a5)
  330.         ;beq    .NOMSGPORT
  331.         ;push    a0
  332.         ;movea.l    d0,a1
  333.         ;move.l    #NULL,(LN_NAME,a1)
  334.         ;CALL    AddPort
  335.         ;pop    a0
  336.  
  337. ;--------------    copy base
  338.         lea    (sdevbase_Name,a5),a1
  339.         moveq    #MAX_BASENAME-2,d1
  340. .CopyBaseName    move.b    (a0)+,d0
  341.         beq    .FAILURE
  342.         cmpi.b    #",",d0
  343.         beq.b    .NameFound
  344.         UCASE    d0
  345.         move.b    d0,(a1)+
  346.         dbra    d1,.CopyBaseName
  347.         bra    .BaseTooLong
  348. .NameFound    clr.b    (a1)+
  349.         move.l    a0,d7        ; d7 = device name
  350.  
  351.         move.l    #IOSTD_SIZE,(sdevbase_IOSize,a5)
  352.         move.l    #-1,(sdevbase_Unit,a5) ; any unit will do
  353.  
  354. .FindEnd    move.b    (a0)+,d0
  355.         beq.b    .EndFound
  356.  
  357. ;--------------    another comma indicates the user wants to give an IO size (default=IOSTD_SIZE)
  358.         cmpi.b    #",",d0
  359.         bne.b    .FindEnd
  360.         clr.b    (-1,a0)
  361.         moveq    #STVFORMAT_DEC,d0
  362.         jsr    StringToValue
  363.         move.l    d0,(sdevbase_IOSize,a5)    ; set unit
  364.  
  365. ;--------------    another comma indicates the user wants to give a unit (default=0)
  366. .FindEnd2    move.b    (a0)+,d0
  367.         cmpi.b    #",",d0
  368.         bne.b    .FindEnd
  369.         clr.b    (-1,a0)
  370.         moveq    #STVFORMAT_DEC,d0
  371.         jsr    StringToValue
  372.         move.l    d0,(sdevbase_Unit,a5)    ; set unit
  373.         bra.b    .GoOn
  374.  
  375. ;--------------    we have to remove trailing whitespaces because the library name
  376. ;--------------    is to be directly transfered to OpenLibrary() which otherwise
  377. ;--------------    could fail
  378. .EndFound    subq.l    #1,a0
  379. .WhileIsWhite    cmpa.l    d7,a0
  380.         beq.b    .WhiteIsDone
  381.         move.b    -(a0),d0
  382.         cmpi.b    #" ",d0
  383.         beq.b    .WhileIsWhite
  384.         cmpi.b    #"    ",d0
  385.         beq.b    .WhileIsWhite
  386. .WhiteIsDone    clr.b    (1,a0)
  387.  
  388. ;--------------    now try to open the device
  389. ;--------------    note that what we do here is really not very smart, but it works:
  390. ;--------------    we find the device by name and "lock" it by adding an openlib count
  391.  
  392. .GoOn        CALL    Forbid,<(execBase).w>
  393.         movea.l    d7,a1            ; name
  394.         lea    (DeviceList,a6),a0    ; start
  395.         CALL    FindName
  396.         move.l    d0,(sdevbase_Device,a5)
  397.         beq.b    .CannotOpenDev
  398.         movea.l    d0,a1
  399.         addq.w    #1,(LIB_OPENCNT,a1)
  400.         move.b    (LIB_FLAGS,a1),d0
  401.         bset    #LIBB_CHANGED,d0
  402.         move.b    d0,(LIB_FLAGS,a1)
  403.         CALL    SumLibrary
  404.         CALL    Permit
  405.  
  406.         moveq    #ERROR_NONE,d0
  407.         bra.b    SetDevice_done
  408.  
  409. ;--------------    base name exceeds MAX_BASENAME
  410. .BaseTooLong    lea    (basesizeErr,pc),a0
  411.         bra.b    .SHOWERROR
  412.  
  413. ;--------------    unable to OpenLibrary()
  414. .CannotOpenDev    CALL    Permit
  415.         lea    (opendevErr,pc),a0
  416.         move.l    d7,outputArgs+4
  417. .SHOWERROR    bsr    ParserError
  418.         bra.b    SetDevice_done
  419.  
  420. .NOMSGPORT    lea    (msgportErr,pc),a0
  421.         bra.b    .SHOWERROR
  422.  
  423. .NoMemory    moveq    #ERROR_NOT_ENOUGH_MEMORY,d0
  424.         bra.b    SetDevice_done
  425.  
  426. .FAILURE    moveq    #ERROR_INVALID_LINE,d0
  427.         DONE    SetDevice
  428.  
  429. ***********************************************************************************
  430. ;--------------    define a new offset
  431. ;--------------    
  432. ;--------------    => a0: APTR current string position
  433.  
  434.         ENTRY    SetDefine,d1-d7/a0-a6
  435.         move.l    a0,d7
  436.  
  437. ;--------------    find start of offset
  438. .FindComma    move.b    (a0)+,d0
  439.         beq    .InvalidLine
  440.         cmpi.b    #",",d0
  441.         bne.b    .FindComma
  442.         clr.b    (-1,a0)
  443.         moveq    #STVFORMAT_DEC,d0
  444.         jsr    StringToValue
  445.         move.l    d0,d6
  446.  
  447. ;--------------    allocate new define
  448.         lea    (defines),a1
  449.         move.l    #sdef_SIZEOF,d0
  450.         bsr    CreateEntry
  451.         tst.l    d0
  452.         beq.b    .NoMemory
  453.         
  454.         move.l    d6,(sdef_Offset,a5)
  455.         lea    (sdef_Name,a5),a1
  456.         movea.l    d7,a0
  457.         moveq    #MAX_DEFINENAME-1,d0
  458. .STRCPY        move.b    (a0)+,(a1)+
  459.         beq.b    .STRCPYEND
  460.         dbra    d0,.STRCPY
  461.  
  462. ;--------------    error, define name too long
  463.         lea    (defsizeErr,pc),a0
  464.         bsr    ParserError
  465.         bra.b    SetDefine_done
  466.  
  467. .InvalidLine    moveq    #ERROR_INVALID_LINE,d0
  468.         bra.b    SetDefine_done
  469.  
  470. .NoMemory    moveq    #ERROR_NOT_ENOUGH_MEMORY,d0
  471.         bra.b    SetDefine_done
  472.  
  473. .STRCPYEND    moveq    #ERROR_NONE,d0
  474.         DONE    SetDefine
  475.  
  476. ***********************************************************************************
  477. ;--------------    define a new offset
  478. ;--------------    
  479. ;--------------    => a0: APTR current string position
  480.  
  481.         ENTRY    SetBitdef,d1-d7/a0-a6
  482.         move.l    a0,d7
  483.  
  484. ;--------------    find start of offset
  485. .FindComma    move.b    (a0)+,d0
  486.         beq    .InvalidLine
  487.         cmpi.b    #",",d0
  488.         bne.b    .FindComma
  489.         clr.b    (-1,a0)
  490.         moveq    #STVFORMAT_DEC,d0
  491.         jsr    StringToValue
  492.         moveq    #0,d6
  493.         bset    d0,d6
  494.  
  495. ;--------------    allocate new define
  496.         lea    (defines),a1
  497.         move.l    #sdef_SIZEOF,d0
  498.         bsr    CreateEntry
  499.         tst.l    d0
  500.         beq.b    .NoMemory
  501.         
  502.         move.l    d6,(sdef_Offset,a5)
  503.         lea    (sdef_Name,a5),a1
  504.         movea.l    d7,a0
  505.         moveq    #MAX_DEFINENAME-1,d0
  506. .STRCPY        move.b    (a0)+,(a1)+
  507.         beq.b    .STRCPYEND
  508.         dbra    d0,.STRCPY
  509.  
  510. ;--------------    error, define name too long
  511.         lea    (defsizeErr,pc),a0
  512.         bsr    ParserError
  513.         bra.b    SetBitdef_done
  514.  
  515. .InvalidLine    moveq    #ERROR_INVALID_LINE,d0
  516.         bra.b    SetBitdef_done
  517.  
  518. .NoMemory    moveq    #ERROR_NOT_ENOUGH_MEMORY,d0
  519.         bra.b    SetBitdef_done
  520.  
  521. .STRCPYEND    moveq    #ERROR_NONE,d0
  522.         DONE    SetBitdef
  523.  
  524.  
  525. ***********************************************************************************
  526. ;--------------    include a file
  527. ;--------------    
  528. ;--------------    => a0: APTR filename
  529.         STRUCTURE siStack,0
  530.         APTR    sis_Handle
  531.         LONG    sis_Line
  532.         LABEL    sis_SIZEOF
  533.  
  534.         ENTRY    SetInclude,d1-d7/a0-a6,sis_SIZEOF,a4
  535.  
  536. ;--------------    FIRST: try to find file in local directory
  537.         move.l    a0,d1
  538.         move.l    a0,d7
  539.         move.l    d1,(outputArgs)
  540.         move.l    #MODE_OLDFILE,d2
  541.         CALL    Open,<(dosBase)>
  542.         move.l    d0,(sis_Handle,a4)
  543.         bne.b    .FileFound
  544.  
  545. ;--------------    build includefile name
  546.         lea    (incdirBuffer),a1
  547.         lea    (includeName),a2
  548.         STRCPY    a1,a2
  549.  
  550. ;--------------    create filename
  551.         move.l    #includeName,d1
  552.         move.l    d7,d2
  553.         move.l    #MAX_INCDIRNAME,d3
  554.         CALL    AddPart
  555.  
  556. ;--------------    open file
  557.         move.l    #includeName,d1
  558.         move.l    d1,(outputArgs+4)
  559.         move.l    #MODE_OLDFILE,d2
  560.         CALL    Open
  561.         move.l    d0,(sis_Handle,a4)
  562.         beq.b    .NoFile
  563.  
  564. ;--------------    this is really not a very smart way of preventing
  565. ;--------------    "endless include loops" but it works
  566. .FileFound    cmpi.b    #MAX_INCLUDELEVEL,(includeLevel)
  567.         beq.b    .LEVELOVERFLOW
  568.         addq.b    #1,(includeLevel)
  569.  
  570. ;--------------    read all lines one-by-one
  571. .LOOP        move.l    (sis_Handle,a4),d1
  572.         move.l    #inputMemory,d2
  573.         move.l    #MAX_INPUT,d3
  574.         CALL    FGets
  575.         tst.l    d0
  576.         beq.b    .DONE
  577.         addq.l    #1,(sis_Line,a4)
  578.         move.l    (sis_Line,a4),(currentLine)
  579.         bsr    ProcessInput
  580.         tst.l    d0
  581.         bne.b    .FAIL
  582.         bra.b    .LOOP
  583.  
  584. ;--------------    FGets() returned NULL; so we have to check if it was EOF or an error
  585. .DONE        CALL    IoErr
  586.         move.l    d0,d1
  587.         beq.b    .ReallyDone
  588.  
  589. ;--------------    it WAS an error, so show it and exit
  590.         jsr    ShowDosError
  591. .FAIL        move.l    (sis_Handle,a4),d1
  592.         CALL    Close
  593.         subq.b    #1,(includeLevel)
  594.         moveq    #ERROR_INTERNAL,d0
  595.         bra.b    SetInclude_done
  596.  
  597. ;--------------    return to sender
  598. .ReallyDone    move.l    (sis_Handle,a4),d1
  599.         CALL    Close
  600.         subq.b    #1,(includeLevel)
  601.         moveq    #ERROR_NONE,d0
  602.         bra.b    SetInclude_done
  603.  
  604. ;--------------    too many include files
  605. .LEVELOVERFLOW    move.l    (sis_Handle,a4),d1
  606.         CALL    Close
  607.         lea    (inclevelErr,pc),a0
  608.         bra.b    .SHOWERROR
  609.  
  610. ;--------------    some error message
  611. .NoFile        lea    (openincErr,pc),a0
  612. .SHOWERROR    bsr    ParserError
  613.         DONE    SetInclude
  614.  
  615. ***********************************************************************************
  616. ;--------------    set new directory for includes
  617. ;--------------    
  618.         ENTRY    SetIncdir,d1-d7/a0-a6
  619.  
  620. ;--------------    copy name to incdir Buffer
  621.         lea    (incdirBuffer),a1
  622.         move.w    #MAX_INCDIRNAME-1,d0
  623. .STRCPY        move.b    (a0)+,(a1)+
  624.         beq.b    .STRCPYEND
  625.         dbra    d0,.STRCPY
  626.  
  627. ;--------------    error, define name too long
  628.         lea    (incdirsizeErr,pc),a0
  629.         bsr    ParserError
  630.         bra.b    SetIncdir_done
  631.  
  632. ;--------------    return success
  633. .STRCPYEND    moveq    #ERROR_NONE,d0
  634.         DONE    SetIncdir
  635.  
  636. **************************************************************************
  637. ;--------------    various boolean flags
  638. SetSticky    lea    (argSticky),a1
  639.         bra    FindBooleanKeyword
  640. SetMatch    lea    (argMatch),a1
  641.         bra    FindBooleanKeyword
  642. SetTaskInfo    lea    (argTaskInfo),a1
  643.         bra    FindBooleanKeyword
  644. SetSegTracker    lea    (flagSegTracker),a1
  645.         bra    FindBooleanKeyword
  646. SetSkipSimilar    lea    (flagSkipSimilar),a1
  647.         bra    FindBooleanKeyword
  648. SetSkipSegNotFound
  649.         lea    (flagSkipSegNotFound),a1
  650.         bra    FindBooleanKeyword
  651.  
  652. ***********************************************************************************
  653. ;--------------    define a new offset
  654. ;--------------    
  655. ;--------------    => a0: APTR current string position
  656. SetHide        lea    (hides),a1
  657.         bra    SetTask
  658. SetShow        lea    (shows),a1
  659.         move.b    #1,(showsactive)
  660.         bra    SetTask
  661.  
  662.         ENTRY    SetTask,d1-d7/a0-a6
  663.  
  664. ;--------------    allocate new task information
  665.         move.l    #stask_SIZEOF,d0
  666.         bsr    CreateEntry
  667.         tst.l    d0
  668.         beq.b    .NoMemory
  669.  
  670. ;--------------    if it starts with a $ its assumed to be an address
  671.         cmpi.b    #"$",(a0)
  672.         bne.b    .ITSANAME
  673.         cmpi.b    #"$",(1,a0)
  674.         bne.b    .ITSAPOINTER
  675. .ITSANAME    lea    (stask_Name,a5),a1
  676.         moveq    #MAX_TASKNAME-1,d0
  677. .STRCPY        move.b    (a0)+,(a1)+
  678.         beq.b    .STRCPYEND
  679.         dbra    d0,.STRCPY
  680.  
  681. ;--------------    error, define name too long
  682.         lea    (tasksizeErr,pc),a0
  683.         bsr    ParserError
  684.         bra.b    SetTask_done
  685.  
  686. .NoMemory    moveq    #ERROR_NOT_ENOUGH_MEMORY,d0
  687.         bra.b    SetTask_done
  688.  
  689. ;--------------    its a pointer; get its address
  690. .ITSAPOINTER    moveq    #STVFORMAT_HEX,d0
  691.         jsr    StringToValue
  692.         move.l    d0,(stask_Pointer,a5)
  693. .STRCPYEND    moveq    #ERROR_NONE,d0
  694.         DONE    SetTask
  695.  
  696. **************************************************************************
  697. ;--------------    display a message in the output file
  698. ;--------------    
  699. SetEcho        jsr    ShowEchoMessage
  700.         tst.w    d0
  701.         beq    .FAIL
  702.         moveq    #ERROR_NONE,d0
  703.         rts
  704. .FAIL        moveq    #ERROR_ABORT,d0
  705.         rts
  706.  
  707. ***********************************************************************************
  708. ;--------------    define a new alias
  709. ;--------------    
  710.         ENTRY    SetAlias,d1-d7/a0-a6
  711.         move.l    a0,d7
  712.  
  713. ;--------------    find start of offset
  714. .FindComma    move.b    (a0)+,d0
  715.         beq.b    .InvalidLine
  716.         cmpi.b    #",",d0
  717.         bne.b    .FindComma
  718.         clr.b    (-1,a0)
  719.         move.l    a0,d6        ; d6 = TEMPLATE, d7 = ALIAS
  720.     
  721. ;--------------    allocate new define
  722.         move.l    #salias_SIZEOF,d0
  723.         lea    (aliases),a1
  724.         bsr    CreateEntry
  725.         tst.l    d0
  726.         beq.b    .NoMemory
  727.  
  728. ;--------------    copy alias name
  729.         lea    (salias_Name,a5),a1
  730.         movea.l    d7,a0
  731.         moveq    #MAX_ALIASNAME-1,d0
  732. .STRCPY1    move.b    (a0)+,(a1)+
  733.         beq.b    .STRCPYEND1
  734.         dbra    d0,.STRCPY1
  735.         lea    (aliasnameErr,pc),a0
  736. .SHOWERROR    bsr    ParserError
  737.         bra.b    SetAlias_done
  738.  
  739. ;--------------    copy alias contents
  740. .STRCPYEND1    lea    (salias_Contents,a5),a1
  741.         movea.l    d6,a0
  742.         move.w    #MAX_ALIASCONTENTS-1,d0
  743. .STRCPY2    move.b    (a0)+,(a1)+
  744.         beq.b    .STRCPYEND2
  745.         dbra    d0,.STRCPY2
  746.         lea    (aliascontentErr,pc),a0
  747.         bra.b    .SHOWERROR
  748. .STRCPYEND2    moveq    #ERROR_NONE,d0
  749.         bra.b    SetAlias_done
  750.     
  751. .NoMemory    moveq    #ERROR_NOT_ENOUGH_MEMORY,d0
  752.         bra.b    SetAlias_done
  753.  
  754. .InvalidLine    moveq    #ERROR_INVALID_LINE,d0
  755.         DONE    SetAlias
  756.  
  757. **************************************************************************
  758. ;--------------    
  759.         ENTRY    SetAssume,d1-d7/a0-a6
  760.         lea    (AssumeKeys,pc),a3
  761. .LOOP        move.w    (a3),d0
  762.         beq.b    .FAILED
  763.         lea    (AssumeKeys,pc),a4
  764.         lea    (a4,d0.w),a4    ; a4 = string to match
  765.         movea.l    a0,a2        ; a2 = current string
  766. .STRICMP    move.b    (a4)+,d0
  767.         beq.b    .Found
  768.         move.b    (a2)+,d1
  769.         UCASE    d1
  770.         cmp.b    d1,d0
  771.         beq.b    .STRICMP
  772. .NEXT        addq.l    #4,a3
  773.         bra.b    .LOOP
  774. .Found        move.b    (a2)+,d1
  775.         beq.b    .SUCCESS
  776.         cmpi.b    #' ',d1
  777.         beq.b    .SUCCESS
  778.         cmpi.b    #'    ',d1
  779.         bne.b    .NEXT
  780. .SUCCESS    move.w    (2,a3),d0
  781.         move.b    d0,(assume)
  782.         moveq    #ERROR_NONE,d0
  783.         bra.b    SetAssume_done
  784.  
  785. ;--------------    display warning
  786. .FAILED        move.l    a0,(outputArgs+4)
  787.         lea    (invassumeErr,pc),a0
  788.         bsr    ParserError        
  789.         DONE    SetAssume
  790.  
  791. **************************************************************************
  792. ;--------------    set running priority
  793.         ENTRY    SetPri
  794.         moveq    #STVFORMAT_DEC,d0
  795.         jsr    StringToValue
  796.         move.l    d0,(priority)
  797.         moveq    #ERROR_NONE,d0
  798.         DONE    SetPri
  799.  
  800. **************************************************************************
  801. ;--------------    set timeout delay
  802.         ENTRY    SetTimeout
  803.         moveq    #STVFORMAT_DEC,d0
  804.         jsr    StringToValue
  805.         move.l    d0,(timeout)
  806.         moveq    #ERROR_NONE,d0
  807.         DONE    SetTimeout
  808.  
  809. **************************************************************************
  810. ;--------------    set output handle
  811.         ENTRY    SetOutput,d1-d7/a0-a6
  812.         lea    (outputMemory),a1
  813.         STRCPY    a0,a1
  814.         moveq    #ERROR_NONE,d0
  815.         DONE    SetOutput
  816.  
  817. **************************************************************************
  818. ;--------------    define a new library snooper
  819. ;--------------    
  820.         ENTRY    SetWatch,d1-d7/a0-a6
  821.  
  822. ;--------------    create new patch entry
  823.         move.l    a0,d7
  824.         move.l    #spatch_SIZEOF,d0
  825.         lea    (watches),a1
  826.         bsr    CreateEntry
  827.         tst.l    d0
  828.         beq    .NoMemory
  829.  
  830. ;--------------    NEW: Setup flags
  831.         moveq    #0,d0
  832.         tst.l    (flagSegTracker)
  833.         bne.b    .STOFF
  834.         bset    #SINFOB_NOSEGTRACKER,d0
  835. .STOFF        tst.l    (flagSkipSimilar)
  836.         beq.b    .SSOFF
  837.         bset    #SINFOB_SKIPSIMILAR,d0
  838. .SSOFF        move.l    d0,(spatch_Flags,a5)
  839.         move.l    (timeout),(spatch_Timeout,a5)
  840.  
  841. ;--------------    try to find a base for this watch
  842.         lea    (bases),a1
  843.         movea.l    (LH_HEAD,a1),a1
  844. .FindBaseLOOP    tst.l    (LN_SUCC,a1)    ; a1 = current node
  845.         beq    .NoBaseFound
  846.         lea    (sbase_Name,a1),a2
  847.         movea.l    d7,a0
  848. .STRICMP    move.b    (a0)+,d0
  849.         UCASE    d0
  850.         move.b    (a2)+,d1
  851.         beq.b    .BaseFound
  852.         cmp.b    d1,d0
  853.         beq.b    .STRICMP
  854.         movea.l    (LN_SUCC,a1),a1
  855.         bra.b    .FindBaseLOOP
  856. .BaseFound    move.l    (sbase_Library,a1),(spatch_Library,a5)
  857.  
  858. ;--------------    find Offset
  859.         movea.l    d7,a0
  860. .FindFirstComma    move.b    (a0)+,d0
  861.         beq    .InvalidLine
  862.         cmpi.b    #",",d0
  863.         bne.b    .FindFirstComma
  864.  
  865. ;--------------    NEW: if its not '-' or a digit, fail
  866.         cmpi.b    #"-",(a0)
  867.         beq.b    .ITSADIGIT
  868.         IFDIGIT    (a0),.ITSADIGIT
  869.         bsr    FindDefine
  870.         tst.w    d0
  871.         beq.b    .OffsetNotFound
  872.         move.w    d1,(spatch_Offset,a5)
  873. .SKIP_Comma    cmpi.b    #",",(a0)+
  874.         bne.b    .SKIP_Comma
  875.         bra.b    .OFFSETFOUND
  876. .ITSADIGIT    moveq    #STVFORMAT_DEC,d0
  877.         jsr    StringToValue
  878.         move.w    d0,(spatch_Offset,a5)
  879. .OFFSETFOUND
  880. ;--------------    now parse the register information
  881.         bsr    ParseRegisterInfo
  882.         tst    d0
  883.         beq.b    .InvalidLine
  884.  
  885. ;--------------    the rest of this line is interpreted as the argument template
  886.         lea    (spatch_Template,a5),a1
  887.         move.w    #MAX_TEMPLATE-2,d0
  888. .CopyTemplate    move.b    (a0)+,(a1)+
  889.         beq.b    .SUCCESS
  890.         dbra    d0,.CopyTemplate
  891.         lea    (tempsizeErr,pc),a0
  892.         bsr    ParserError
  893.         bra.b    SetWatch_done
  894.  
  895. ;--------------    return successfully
  896. .SUCCESS    moveq    #ERROR_NONE,d0
  897.         bra.b    SetWatch_done
  898.  
  899. ;--------------    library base could not be found
  900. .NoBaseFound    lea    (nobaseErr,pc),a0
  901. .SHOWERROR    bsr    ParserError
  902.         bra.b    SetWatch_done
  903.  
  904. ;--------------    offset not found
  905. .OffsetNotFound    move.l    a0,(outputArgs+4)
  906. .ONFLOOP    move.b    (a0)+,d0
  907.         beq.b    .ONFDONE
  908.         cmpi.b    #",",d0
  909.         bne.b    .ONFLOOP
  910.         clr.b    -(a0)
  911. .ONFDONE    lea    (nooffsetErr,pc),a0
  912.         bra.b    .SHOWERROR
  913.  
  914. .InvalidLine    moveq    #ERROR_INVALID_LINE,d0
  915.         bra.b    SetWatch_done
  916.  
  917. .NoMemory    moveq    #ERROR_NOT_ENOUGH_MEMORY,d0
  918.         DONE    SetWatch
  919.  
  920. ***********************************************************************************
  921. ;--------------    read in register information stored in a syntax of
  922. ;--------------    
  923. ;--------------     <register 0>/<register 1>/.../<register n>
  924. ;--------------    
  925. ;--------------    where <register x> is
  926. ;--------------    
  927. ;--------------        [R|B]((D|A)<0..7>)[L|W|b][:<offset>]
  928. ;--------------    
  929. ;--------------    => A0: APTR start of register information
  930. ;--------------       A5: struct PatchInfo *pi
  931. ;--------------    
  932.  
  933.         ENTRY    ParseRegisterInfo,d1-d7/a1-a6
  934.         moveq    #0,d5        ; current argument counter
  935.  
  936.         lea    (spatch_Arguments,a5),a4    ; load register data in a4
  937.         cmpi.b    #",",(a0)+
  938.         beq    .EmptyReglist
  939.         subq.l    #1,a0
  940. .LOOP        moveq    #0,d0
  941.  
  942. ;--------------    set size assumption
  943.         cmpi.b    #ASSUME_BYTE,(assume)
  944.         beq    .ASSUME_BYTE
  945.         cmpi.b    #ASSUME_LONG,(assume)
  946.         beq    .ASSUME_LONG
  947.         bra    .ASSUME_WORD    ; "default"
  948.  
  949. ;--------------    handle register
  950. .GetRegister    move.b    (a0)+,d1
  951.         beq    .InvalidLine
  952.         UCASE    d1
  953.  
  954. ;--------------    a leading R signals that this register is a return value
  955.         cmpi.b    #"R",d1
  956.         bne.b    .NotReturn
  957.         bset    #REGB_RESULT,d0
  958.         bra.b    .GetRegister
  959. .NotReturn    
  960. ;--------------    a leading B signals that this register is a boolean value
  961.         cmpi.b    #"B",d1
  962.         bne.b    .NotBoolean
  963.         bset    #REGB_BOOLEAN,d0
  964.         bra.b    .GetRegister
  965. .NotBoolean
  966. ;--------------    a D is for data registers
  967.         cmpi.b    #"D",d1
  968.         bne.b    .NotData
  969.         move.b    (a0)+,d1
  970.         beq    .InvalidLine
  971.         subi.b    #"0",d1
  972.         andi.b    #%111,d1
  973.         or.b    d1,d0
  974.         bset    #REGB_DATA,d0
  975.         bra.b    .GetRegister
  976.  
  977. ;--------------    an A stands for address registers
  978. .NotData    cmpi.b    #"A",d1
  979.         bne.b    .NotAddr
  980.         move.b    (a0)+,d1
  981.         beq    .InvalidLine
  982.         subi.b    #"0",d1
  983.         andi.b    #%111,d1
  984.         or.b    d1,d0
  985.         bset    #REGB_ADDR,d0
  986.         bra.b    .GetRegister
  987.  
  988. ;--------------    an I stands for address registers relative
  989. .NotAddr    cmpi.b    #"I",d1
  990.         bne.b    .NotRelative
  991.         move.b    (a0)+,d1
  992.         beq    .InvalidLine
  993.         subi.b    #"0",d1
  994.         andi.b    #%111,d1
  995.         or.b    d1,d0
  996.         bset    #REGB_INDIRECT,d0
  997.         bra    .GetRegister
  998. .NotRelative
  999. ;--------------    a trailing L stands for LONG
  1000.         cmpi.b    #"L",d1
  1001.         bne.b    .NotLong
  1002. .ASSUME_LONG    bset    #REGB_LONG,d0
  1003.         bclr    #REGB_WORD,d0
  1004.         bclr    #REGB_BYTE,d0
  1005.         bra    .GetRegister
  1006. .NotLong
  1007. ;--------------    a trailing W stands for WORD
  1008.         cmpi.b    #"W",d1
  1009.         bne.b    .NotWord
  1010. .ASSUME_WORD    bclr    #REGB_LONG,d0
  1011.         bset    #REGB_WORD,d0
  1012.         bclr    #REGB_BYTE,d0
  1013.         bra    .GetRegister
  1014. .NotWord
  1015. ;--------------    a trailing b stands for WORD
  1016.         cmpi.b    #"b",d1
  1017.         bne.b    .NotByte
  1018. .ASSUME_BYTE    bclr    #REGB_LONG,d0
  1019.         bclr    #REGB_WORD,d0
  1020.         bset    #REGB_BYTE,d0
  1021.         bra    .GetRegister
  1022. .NotByte
  1023. ;--------------    a ':' indicates start of an offset definition
  1024.         cmpi.b    #":",d1
  1025.         bne.b    .NotOffset
  1026.         pushm    d1-d7/a0-a6
  1027.         bsr    FindDefine
  1028.         tst.w    d0
  1029.         bne.b    .FindSlash
  1030.         moveq    #STVFORMAT_DEC,d0
  1031.         push    a0
  1032.         jsr    StringToValue
  1033.         pop    d2
  1034.         addq.l    #1,d2
  1035.         moveq    #TRUE,d1
  1036.         cmpa.l    d2,a0
  1037.         bne.b    .DigitFound
  1038.         moveq    #FALSE,d1
  1039. .DigitFound    exg.l    d0,d1
  1040. .FindSlash    move.l    d1,(sarg_Offset,a4)
  1041.         popm    d1-d7/a0-a6
  1042.         tst.w    d0
  1043.         beq.b    .InvalidLine
  1044.  
  1045. ;--------------    must be limited with a / or a ','
  1046. .FindSlashLoop    move.b    (a0)+,d1
  1047.         beq.b    .InvalidLine
  1048.         cmpi.b    #'/',d1
  1049.         beq.b    .SlashFound
  1050.         cmpi.b    #',',d1
  1051.         beq.b    .CommaFound
  1052.         bra.b    .FindSlashLoop
  1053. .NotOffset
  1054. ;--------------    a slash / indicates the end of one register definition, so position
  1055. ;--------------    to the next register slot
  1056.         cmpi.b    #"/",d1
  1057.         bne.b    .NotSlash
  1058. .SlashFound    move.w    d0,(a4)
  1059.         lea    (sarg_SIZEOF,a4),a4
  1060.         addq.l    #1,d5
  1061.         cmpi.l    #MAX_ARGUMENTS,d5
  1062.         beq.b    .TOOMANYARGS
  1063.         bra    .LOOP
  1064. .NotSlash
  1065. ;--------------    a comma , indicates the end of the register list definition
  1066.         cmpi.b    #",",d1
  1067.         bne.b    .InvalidLine
  1068. .CommaFound    move.w    d0,(a4)
  1069.         lea    (sarg_SIZEOF,a4),a4
  1070.         addq.l    #1,d5
  1071.         cmpi.l    #MAX_ARGUMENTS,d5
  1072.         beq    .TOOMANYARGS
  1073. .EmptyReglist    move.w    #REG_DONE,(a4)
  1074.         moveq    #TRUE,d0
  1075.         bra.b    ParseRegisterInfo_done
  1076.  
  1077. .TOOMANYARGS    lea    (argsizeErr,pc),a0
  1078.         bsr    ParserError
  1079.         bra.b    ParseRegisterInfo_done
  1080.  
  1081. .InvalidLine    moveq    #FALSE,d0
  1082.         DONE    ParseRegisterInfo
  1083.  
  1084. **************************************************************************
  1085. ;--------------    define a new device snooper
  1086. ;--------------    
  1087. ;--------------    devcmd=<device>,<command>,<offsets>,<register list>
  1088. ;--------------    
  1089. ;--------------    
  1090.  
  1091. SetBeginIO    moveq    #SINFOF_BEGINIO,d5
  1092.         bra.b    HandleDevCmd
  1093.  
  1094. SetAbortIO    moveq    #SINFOF_ABORTIO,d5
  1095.         bra.b    HandleDevCmd
  1096.  
  1097. SetDevCmd    moveq    #SINFOF_BEGINIO|SINFOF_ABORTIO,d5
  1098.         ;bra.b    HandleDevCmd
  1099.  
  1100.         ENTRY    HandleDevCmd,d1-d7/a0-a6
  1101.  
  1102. ;--------------    try to find the device base for this watch
  1103.         lea    (deviceBases),a1
  1104.         movea.l    (LH_HEAD,a1),a1
  1105.         move.l    a0,d7
  1106. .FindBaseLOOP    tst.l    (LN_SUCC,a1)    ; a1 = current node
  1107.         beq    .NoBaseFound
  1108.         lea    (sdevbase_Name,a1),a2
  1109.         movea.l    d7,a0
  1110. .STRICMP    move.b    (a0)+,d0
  1111.         UCASE    d0
  1112.         move.b    (a2)+,d1
  1113.         beq.b    .BaseFound
  1114.         cmp.b    d1,d0
  1115.         beq.b    .STRICMP
  1116.         movea.l    (LN_SUCC,a1),a1
  1117.         bra.b    .FindBaseLOOP
  1118. .BaseFound    move.l    (sdevbase_Device,a1),d6
  1119.  
  1120. ;--------------    NOTE: unlike library WATCHes, DEVCMDs are stored in list 
  1121. ;-------------- of the device structures; this makes it later easier to
  1122. ;--------------    display the device messages. 
  1123.         lea    (sdevbase_Patches,a1),a1
  1124.         move.l    #spatch_SIZEOF,d0
  1125.         bsr    CreateEntry
  1126.         tst.l    d0
  1127.         beq    .NoMemory
  1128.         move.l    d6,(spatch_Library,a5) ; (struct Device *)
  1129.  
  1130. ;--------------    NEW: Setup flags
  1131.         moveq    #0,d0
  1132.         or.w    d5,d0
  1133.         tst.l    (flagSegTracker)
  1134.         bne.b    .STOFF
  1135.         bset    #SINFOB_NOSEGTRACKER,d0
  1136. .STOFF        tst.l    (flagSkipSimilar)
  1137.         beq.b    .SSOFF
  1138.         bset    #SINFOB_SKIPSIMILAR,d0
  1139. .SSOFF        move.l    d0,(spatch_Flags,a5)
  1140.  
  1141. ;--------------    find Offset
  1142.         movea.l    d7,a0
  1143. .FindFirstComma    move.b    (a0)+,d0
  1144.         beq    .InvalidLine
  1145.         cmpi.b    #",",d0
  1146.         bne.b    .FindFirstComma
  1147.  
  1148. ;--------------    NEW: if its not '-' or a digit, fail
  1149.         cmpi.b    #"-",(a0)
  1150.         beq.b    .ITSADIGIT
  1151.         IFDIGIT    (a0),.ITSADIGIT
  1152.         bsr    FindDefine
  1153.         tst.w    d0
  1154.         beq.b    .OffsetNotFound
  1155.         move.w    d1,(spatch_Offset,a5)
  1156. .SKIP_Comma    cmpi.b    #",",(a0)+
  1157.         bne.b    .SKIP_Comma
  1158.         bra.b    .OFFSETFOUND
  1159. .ITSADIGIT    moveq    #STVFORMAT_DEC,d0
  1160.         jsr    StringToValue
  1161.         move.w    d0,(spatch_Offset,a5)
  1162. .OFFSETFOUND
  1163. ;--------------    now parse the register information
  1164. ;--------------    currently this is the same function that is used by SetWatch();
  1165. ;--------------    Note that YOU SHOULD NOT USE register specifications, but rather
  1166. ;--------------    statements in the form
  1167. ;--------------    
  1168. ;--------------        .../<size>:<offset>/...
  1169. ;--------------    
  1170. ;--------------    such as
  1171. ;--------------    
  1172. ;--------------        .../L:IO_CMD/...
  1173. ;--------------    
  1174.         bsr    ParseRegisterInfo
  1175.         tst    d0
  1176.         beq.b    .InvalidLine
  1177.  
  1178. ;--------------    the rest of this line is interpreted as the argument template
  1179.         lea    (spatch_Template,a5),a1
  1180.         move.w    #MAX_TEMPLATE-2,d0
  1181. .CopyTemplate    move.b    (a0)+,(a1)+
  1182.         beq.b    .SUCCESS
  1183.         dbra    d0,.CopyTemplate
  1184.         lea    (tempsizeErr,pc),a0
  1185.         bsr    ParserError
  1186.         bra.b    HandleDevCmd_done
  1187.  
  1188. ;--------------    return successfully
  1189. .SUCCESS    moveq    #ERROR_NONE,d0
  1190.         bra.b    HandleDevCmd_done
  1191.  
  1192. ;--------------    device base could not be found
  1193. .NoBaseFound    lea    (nodevbaseErr,pc),a0
  1194. .SHOWERROR    bsr    ParserError
  1195.         bra.b    HandleDevCmd_done
  1196.  
  1197. ;--------------    offset not found
  1198. .OffsetNotFound    move.l    a0,(outputArgs+4)
  1199. .ONFLOOP    move.b    (a0)+,d0
  1200.         beq.b    .ONFDONE
  1201.         cmpi.b    #",",d0
  1202.         bne.b    .ONFLOOP
  1203.         clr.b    -(a0)
  1204. .ONFDONE    lea    (nooffsetErr,pc),a0
  1205.         bra.b    .SHOWERROR
  1206.  
  1207. .InvalidLine    moveq    #ERROR_INVALID_LINE,d0
  1208.         bra.b    HandleDevCmd_done
  1209.  
  1210. .NoMemory    moveq    #ERROR_NOT_ENOUGH_MEMORY,d0
  1211.         DONE    HandleDevCmd
  1212.  
  1213. ***********************************************************************************
  1214. ;--------------    try to find a defined number for a function (or io command) offset
  1215. ;--------------    
  1216.         ENTRY    FindDefine,d2-d7/a0-a6
  1217.         movea.l    a0,a4
  1218.         lea    (defines),a5
  1219.         movea.l    (LH_HEAD,a5),a5
  1220. .LOOP        tst.l    (LN_SUCC,a5)    ; a5 = current node
  1221.         beq.b    .NotInList
  1222.         movea.l    a4,a0        ; string to find
  1223.         lea    (sdef_Name,a5),a1 ; definition of String
  1224. .STRICMP    move.b    (a1)+,d0
  1225.         beq.b    .InList
  1226.         move.b    (a0)+,d1
  1227.         cmp.b    d1,d0
  1228.         beq.b    .STRICMP
  1229.         movea.l    (LN_SUCC,a5),a5
  1230.         bra.b    .LOOP
  1231.  
  1232. .InList        cmpi.b    #"/",(a0)+
  1233.         beq.b    .ISINLIST
  1234.         cmpi.b    #",",(-1,a0)
  1235.         bne.b    .NotInList
  1236. .ISINLIST    moveq    #TRUE,d0
  1237.         move.l    (sdef_Offset,a5),d1
  1238.         bra.b    FindDefine_done
  1239.  
  1240. .NotInList    moveq    #FALSE,d0
  1241.         DONE    FindDefine
  1242.  
  1243. **************************************************************************
  1244. ;--------------    try to find the boolean value for a keyword
  1245. ;--------------    
  1246. ;--------------    => a0: APTR string
  1247. ;--------------       a1: APTR flag pointer
  1248.         ENTRY    FindBooleanKeyword,d1-d7/a0-a6
  1249.         lea    (BoolKeys,pc),a3
  1250. .LOOP        move.w    (a3),d0
  1251.         beq.b    .FAILED
  1252.         lea    (BoolKeys,pc),a4
  1253.         lea    (a4,d0.w),a4    ; a4 = string to match
  1254.         movea.l    a0,a2        ; a2 = current string
  1255. .STRICMP    move.b    (a4)+,d0
  1256.         beq.b    .Found
  1257.         move.b    (a2)+,d1
  1258.         UCASE    d1
  1259.         cmp.b    d1,d0
  1260.         beq.b    .STRICMP
  1261. .NEXT        addq.l    #4,a3
  1262.         bra.b    .LOOP
  1263. .Found        move.b    (a2)+,d1
  1264.         beq.b    .SUCCESS
  1265.         cmpi.b    #' ',d1
  1266.         beq.b    .SUCCESS
  1267.         cmpi.b    #'    ',d1
  1268.         bne.b    .NEXT
  1269. .SUCCESS    move.w    (2,a3),d0
  1270.         ext.l    d0
  1271.         move.l    d0,(a1)
  1272.         moveq    #ERROR_NONE,d0
  1273.         bra.b    FindBooleanKeyword_done
  1274.  
  1275. ;--------------    display warning
  1276. .FAILED        move.l    a0,(outputArgs+4)
  1277.         lea    (invalidboolErr,pc),a0
  1278.         bsr    ParserError
  1279.         DONE    FindBooleanKeyword
  1280.  
  1281. **************************************************************************
  1282. ;--------------    this creates a new (internal) structure entry and adds it
  1283. ;--------------    to the top of a given list
  1284. ;--------------    
  1285. ;--------------    => d0: LONG size
  1286. ;--------------       a1: APTR list header
  1287. ;--------------    <= d0 = a5: APTR new entry
  1288. ;--------------    
  1289.         ENTRY    CreateEntry,d1-d7/a0-a4/a6
  1290.         move.l    #MEMF_PUBLIC|MEMF_CLEAR,d1
  1291.         movea.l    a1,a5
  1292.         CALL    AllocMem,<(execBase).w>
  1293.         tst.l    d0
  1294.         beq.b    CreateEntry_done
  1295.         movea.l    a5,a0
  1296.         movea.l    d0,a5
  1297.         movea.l    d0,a1
  1298.         ADDHEAD
  1299.         DONE    CreateEntry
  1300.  
  1301. **************************************************************************
  1302. ;--------------    
  1303.         ENTRY    ParserError,d1-d7/a0-a6
  1304.         lea    (outputArgs),a5
  1305.         push    a0
  1306.         move.l    (currentLine),(a5)        
  1307.         move.l    (4,a5),d7
  1308.         lea    (input),a0
  1309.         move.l    a0,(4,a5)
  1310.         move.b    #'.',(input+30) ; max of 30 characters
  1311.         move.b    #'.',(input+31)
  1312.         move.b    #'.',(input+32)
  1313.         move.b    #0,(input+33)
  1314.         lea    (errorHeader,pc),a0    ; format string
  1315.         lea    (outputArgs),a1        ; format data
  1316.         lea    (errorBuffer),a2    ; target string
  1317.         jsr    SPrintf
  1318.         pop    a0
  1319.         move.l    #errorBuffer,(a5)
  1320.         move.l    d7,(4,a5)
  1321.         jsr    ShowErrorMessage
  1322.         moveq    #ERROR_INTERNAL,d0
  1323.         DONE    ParserError
  1324.  
  1325. ***********************************************************************************
  1326. ;--------------    dealias input line
  1327. ;--------------    
  1328.         ENTRY    PrepareInput,d0-d7/a0-a6
  1329.  
  1330. ;--------------    FIRST PASS: dealias input
  1331.         lea    (inputMemory),a1    ; source
  1332.         lea    (input),a0        ; target
  1333. .COPYINPUT    move.b    (a1)+,d0
  1334.         beq    .DONEPASS1
  1335.  
  1336. ;--------------    if its a $ and the next character is a bracket '(', it could
  1337. ;--------------    be an alias....
  1338.         cmpi.b    #"$",d0
  1339.         bne    .COPYCHAR
  1340.         cmpi.b    #"\\",(-2,a1)
  1341.         beq    .COPYCHAR
  1342.         moveq    #">",d7
  1343.         lea    (defines),a3    ; a3 = current DEFINE
  1344.         cmpi.b    #"<",(a1)
  1345.         beq.b    .DEALIASNUMERIC
  1346.         moveq    #")",d7
  1347.         lea    (aliases),a3    ; a3 = current ALIAS 
  1348.         cmpi.b    #"(",(a1)
  1349.         bne    .COPYCHAR
  1350.         bra.b    .DEALIAS
  1351.  
  1352. ;--------------    defines understand leading '$','%'
  1353. .DEALIASNUMERIC    moveq    #STVFORMAT_DEC,d6    ; current number output
  1354.         cmpi.b    #"$",(1,a1)
  1355.         bne.b    .DEALIAS
  1356.         moveq    #STVFORMAT_HEX,d6
  1357.         addq.l    #1,a1
  1358. .DEALIAS    lea    (1,a1),a2    ; a2 = begin of ALIAS-name
  1359.         movea.l    (LH_HEAD,a3),a3
  1360. .ALIASLOOP    tst.l    (LN_SUCC,a3)
  1361.         beq    .COPYCHAR
  1362.         lea    (salias_Name,a3),a5    ; name to match
  1363.         cmpi.b    #">",d7
  1364.         bne.b    .HANDLEALIAS
  1365.         lea    (sdef_Name,a3),a5    ; name to match
  1366. .HANDLEALIAS    movea.l    a2,a4        ; alias name
  1367. .STRCMP        move.b    (a4)+,d1
  1368.         move.b    (a5)+,d2
  1369.         beq.b    .EOALIAS
  1370.         cmp.b    d2,d1
  1371.         beq.b    .STRCMP
  1372. .NEXTALIAS    movea.l    (LN_SUCC,a3),a3
  1373.         bra.b    .ALIASLOOP
  1374.  
  1375. ;--------------    end of alias name reached; call must close with ')' else its
  1376. ;--------------    not a valid alias
  1377. .EOALIAS    cmp.b    d7,d1
  1378.         bne.b    .NEXTALIAS
  1379.         cmpi.b    #">",d7
  1380.         beq.b    .INSERTDEFINE
  1381.  
  1382. ;--------------    insert contents for alias
  1383.         lea    (salias_Contents,a3),a3
  1384. .INSERTALIAS    move.b    (a3)+,(a0)+
  1385.         bne.b    .INSERTALIAS
  1386.         subq.l    #1,a0
  1387.         movea.l    a4,a1
  1388.         bra    .COPYINPUT
  1389.  
  1390. ;--------------    insert numeric value for define
  1391. .INSERTDEFINE    pushm    d0-d7/a0-a6
  1392.         movea.l    a0,a2            ; a2=target string
  1393.         lea    (insertdecFormat,pc),a0    ; a0=format string
  1394.         cmpi.b    #STVFORMAT_HEX,d6
  1395.         bne.b    .USEDECFORMAT
  1396.         lea    (inserthexFormat,pc),a0    ; a0=format string
  1397. .USEDECFORMAT    lea    (outputArgs),a1        ; a1=format data
  1398.         move.l    (sdef_Offset,a3),(a1)
  1399.         jsr    SPrintf
  1400.         popm    d0-d7/a0-a6
  1401. .SKIPZERO    tst.b    (a0)+
  1402.         bne.b    .SKIPZERO
  1403.         subq.l    #1,a0
  1404.         movea.l    a4,a1
  1405.         bra    .COPYINPUT
  1406.  
  1407. ;--------------    default: copy char
  1408. .COPYCHAR    move.b    d0,(a0)+
  1409.         bra    .COPYINPUT
  1410. .DONEPASS1    clr.b    (a0)+
  1411. ;--------------    (END OF FIRST PASS)
  1412.  
  1413. ;--------------    PASS TWO: remove comments, skip trailing whitespaces
  1414. ;--------------    remove comments and NEWLINE
  1415.         lea    (input),a0
  1416.         cmpi.b    #COMMENT_LINE,(a0)    ; skip if its a comment line
  1417.         beq.b    .SKIPLINE
  1418. .CommentLoop    move.b    (a0)+,d0
  1419.         beq.b    .CommentDone        
  1420.         cmpi.b    #"\\",d0
  1421.         beq.b    .EscapeChar
  1422.         cmpi.b    #COMMENT,d0
  1423.         beq.b    .CommentFound
  1424.         cmpi.b    #"\n",d0
  1425.         bne.b    .CommentLoop    
  1426. .CommentFound    clr.b    -(a0)
  1427. .CommentDone
  1428. ;--------------    skip the line if it only consists of whitespaces
  1429.         lea    (input),a0
  1430. .WhitespaceLoop    move.b    (a0)+,d0
  1431.         beq.b    .SKIPLINE
  1432.         cmpi.b    #" ",d0
  1433.         beq.b    .WhitespaceLoop
  1434.         cmpi.b    #"    ",d0
  1435.         beq.b    .WhitespaceLoop
  1436. .NotWhitespaces    bra.b    PrepareInput_done
  1437.  
  1438. ;--------------    skip whole line
  1439. .SKIPLINE    clr.b    (input)
  1440.         bra.b    PrepareInput_done
  1441.  
  1442. ;--------------    new: support escape characters \\,\n,\t,\e,\;,\$
  1443. .EscapeChar    move.b    (a0),d1
  1444.  
  1445. ;--------------    '\;' results in ';'
  1446.         moveq    #';',d0
  1447.         cmpi.b    #';',d1
  1448.         beq.b    .deleteChar
  1449.  
  1450. ;--------------    '\n' results in '<NEWLINE>'
  1451.         moveq    #10,d0
  1452.         cmpi.b    #'n',d1
  1453.         beq.b    .deleteChar
  1454.         
  1455. ;--------------    '\e' results in '<ESC>'
  1456.         moveq    #'',d0
  1457.         cmpi.b    #'e',d1
  1458.         beq.b    .deleteChar
  1459.         
  1460. ;--------------    '\\' results in '\'
  1461.         moveq    #'\\',d0
  1462.         cmpi.b    #'\\',d1
  1463.         beq.b    .deleteChar
  1464.         
  1465. ;--------------    '\$' results in '$'
  1466.         moveq    #'$',d0
  1467.         cmpi.b    #'$',d1
  1468.         beq.b    .deleteChar
  1469.         
  1470. ;--------------    '\t' results in '<TAB>'
  1471.         moveq    #8,d0
  1472.         cmpi.b    #'\t',d1
  1473.         beq.b    .deleteChar
  1474.         
  1475.         bra.b    .CommentLoop
  1476.  
  1477. .deleteChar    lea    (-1,a0),a1    ; a1=where the former '\' was placed
  1478.         move.b    d0,(a1)+
  1479.         addq.l    #1,a0
  1480.         push    a0
  1481. .DELETECOPY    move.b    (a0)+,(a1)+
  1482.         bne.b    .DELETECOPY
  1483.         pop    a0
  1484.         subq.l    #1,a0
  1485.         bra.b    .CommentLoop
  1486.  
  1487.         DONE    PrepareInput
  1488.  
  1489. **************************************************************************
  1490. ;--------------    add SHOW statements given in the command line
  1491. ;--------------    
  1492.         ENTRY    SetCmdlineSHOWs,d0-d7/a0-a6
  1493.         move.l    (argShow),d0
  1494.         beq.b    .DONE
  1495.         movea.l    d0,a4
  1496. .LOOP        move.l    (a4)+,d1
  1497.         beq.b    .DONE
  1498.         move.l    #stask_SIZEOF,d0
  1499.         lea    (shows),a1
  1500.         bsr    CreateEntry
  1501.         tst    d0
  1502.         beq.b    SetCmdlineSHOWs_done
  1503.         movea.l    d1,a0
  1504.         move.b    #1,(showsactive)
  1505.  
  1506. ;--------------    if it starts with a $ its assumed to be an address
  1507.         cmpi.b    #"$",(a0)
  1508.         bne.b    .ITSANAME
  1509.         cmpi.b    #"$",(1,a0)
  1510.         bne.b    .ITSAPOINTER
  1511. .ITSANAME    lea    (stask_Name,a5),a1
  1512.         moveq    #MAX_TASKNAME-1,d0
  1513. .STRCPY        move.b    (a0)+,(a1)+
  1514.         beq.b    .STRCPYEND
  1515.         dbra    d0,.STRCPY
  1516.  
  1517. ;--------------    error, define name too long
  1518.         lea    (tasksizeErr,pc),a0
  1519.         jsr    ParserError
  1520.         bra.b    SetCmdlineSHOWs_done
  1521.  
  1522. ;--------------    its a pointer; get its address
  1523. .ITSAPOINTER    moveq    #STVFORMAT_HEX,d0
  1524.         jsr    StringToValue
  1525.         move.l    d0,(stask_Pointer,a5)
  1526. .STRCPYEND    moveq    #ERROR_NONE,d0
  1527.         bra.b    .LOOP
  1528. .DONE        moveq    #ERROR_NONE,d0
  1529.         DONE    SetCmdlineSHOWs
  1530.  
  1531. ***********************************************************************************
  1532. ;--------------    structure macro:
  1533. ;--------------    
  1534. ;--------------        STRUCTURE <NAME>,<SIZE>
  1535. ;--------------    
  1536. ;--------------    => a0: APTR current string position
  1537.  
  1538. SetStructure    moveq    #FALSE,d5
  1539.         bra.b    SetSTRUCTURE
  1540. SetSTRUCT    moveq    #TRUE,d5
  1541.         ;bra.b    SetSTRUCTURE
  1542.         ENTRY    SetSTRUCTURE,d1-d7/a0-a6
  1543.         move.l    a0,d7
  1544.  
  1545. ;--------------    find start of offset
  1546. .FindComma    move.b    (a0)+,d0
  1547.         beq    .InvalidLine
  1548.         cmpi.b    #",",d0
  1549.         bne.b    .FindComma
  1550.         clr.b    (-1,a0)
  1551.         moveq    #STVFORMAT_DEC,d0
  1552.         jsr    StringToValue
  1553.         move.l    d0,d6
  1554.  
  1555. ;--------------    allocate new define
  1556.         lea    (defines),a1
  1557.         move.l    #sdef_SIZEOF,d0
  1558.         bsr    CreateEntry
  1559.         tst.l    d0
  1560.         beq.b    .NoMemory
  1561.         
  1562.         tst.w    d5
  1563.         beq.b    .SetStructure
  1564.         move.l    (structureOffset),(sdef_Offset,a5)
  1565.         add.l    d6,(structureOffset)
  1566.         bra.b    .SetContinue
  1567. .SetStructure    move.l    #0,(sdef_Offset,a5) ; not d6!!!!!!!!!!!!!!!!!!!!!!!!
  1568.         move.l    d6,(structureOffset)
  1569. .SetContinue    lea    (sdef_Name,a5),a1
  1570.         movea.l    d7,a0
  1571.         moveq    #MAX_DEFINENAME-1,d0
  1572. .STRCPY        move.b    (a0)+,(a1)+
  1573.         beq.b    .STRCPYEND
  1574.         dbra    d0,.STRCPY
  1575.  
  1576. ;--------------    error, define name too long
  1577.         lea    (defsizeErr,pc),a0
  1578.         bsr    ParserError
  1579.         bra.b    SetSTRUCTURE_done
  1580.  
  1581. .InvalidLine    moveq    #ERROR_INVALID_LINE,d0
  1582.         bra.b    SetSTRUCTURE_done
  1583.  
  1584. .NoMemory    moveq    #ERROR_NOT_ENOUGH_MEMORY,d0
  1585.         bra.b    SetSTRUCTURE_done
  1586.  
  1587. .STRCPYEND    moveq    #ERROR_NONE,d0
  1588.         DONE    SetSTRUCTURE
  1589.  
  1590. ***********************************************************************************
  1591. ;--------------    set structure entry
  1592. ;--------------    
  1593. ;--------------        <element> <NAME>
  1594. ;--------------    
  1595. ;--------------    => a0: APTR current string position
  1596. ;--------------       d6: LONG structure size increment
  1597.  
  1598. SetLONG        moveq    #4,d6
  1599.         bra.b    SetStructureElement
  1600.  
  1601. SetWORD        moveq    #2,d6
  1602.         bra.b    SetStructureElement
  1603.  
  1604. SetBYTE        moveq    #1,d6
  1605.         bra.b    SetStructureElement
  1606.  
  1607. SetLABEL    moveq    #0,d6
  1608.         ;bra.b    SetStructureElement
  1609.         ENTRY    SetStructureElement,d1-d7/a0-a6
  1610.         move.l    a0,d7
  1611.  
  1612. ;--------------    skip trailing whitespaces
  1613. .STRIPWS    move.b    (a0)+,d0
  1614.         beq.b    .STRIPPED
  1615.         cmpi.b    #"    ",d0
  1616.         beq.b    .STRIP
  1617.         cmpi.b    #" ",d0
  1618.         bne.b    .STRIPWS
  1619. .STRIP        clr.b    (-1,a0)
  1620. .STRIPPED
  1621. ;--------------    allocate new define
  1622.         lea    (defines),a1
  1623.         move.l    #sdef_SIZEOF,d0
  1624.         bsr    CreateEntry
  1625.         tst.l    d0
  1626.         beq.b    .NoMemory
  1627.         
  1628.         move.l    (structureOffset),(sdef_Offset,a5) ; not d6!!!!!!!!!!!!!!!!!!!!!!!!
  1629.         add.l    d6,(structureOffset)
  1630.         lea    (sdef_Name,a5),a1
  1631.         movea.l    d7,a0
  1632.         moveq    #MAX_DEFINENAME-1,d0
  1633. .STRCPY        move.b    (a0)+,(a1)+
  1634.         beq.b    .STRCPYEND
  1635.         dbra    d0,.STRCPY
  1636.  
  1637. ;--------------    error, define name too long
  1638.         lea    (defsizeErr,pc),a0
  1639.         bsr    ParserError
  1640.         bra.b    SetStructureElement_done
  1641.  
  1642. .NoMemory    moveq    #ERROR_NOT_ENOUGH_MEMORY,d0
  1643.         bra.b    SetStructureElement_done
  1644.  
  1645. .STRCPYEND    moveq    #ERROR_NONE,d0
  1646.         DONE    SetStructureElement
  1647.  
  1648. SetALIGNWORD    move.l    (structureOffset),d0
  1649.         BRBC.B    #0,d0,.ISEVEN
  1650.         addq.l    #1,(structureOffset)
  1651. .ISEVEN        moveq    #ERROR_NONE,d0
  1652.         rts
  1653.  
  1654. SetALIGNLONG    move.l    (structureOffset),d0
  1655.         BRBC.B    #0,d0,.ISEVEN
  1656.         addq.l    #1,d0
  1657. .ISEVEN        BRBC.B    #1,d0,.ISLONG
  1658.         addq.l    #2,d0
  1659. .ISLONG        move.l    d0,(structureOffset)
  1660.         moveq    #ERROR_NONE,d0
  1661.         rts
  1662.  
  1663. ;--------------    The keyword table describes which commands Snoopy understands.
  1664. ;--------------    NOTE: You can define your personal keyword aliases by adding
  1665. ;--------------    statements that only have a different second argument; example:
  1666. ;--------------    
  1667. ;--------------    keyword Base,LIBRARY
  1668. ;--------------    
  1669. ;--------------    will define the new keyword LIBRARY that is exactly the same as Base
  1670. ;--------------    Define your own keyword handling functions as Set<Name> (SetBase in
  1671. ;--------------    the example above)
  1672. KeywordTable    keyword    RESET
  1673.         keyword    Base,BASE
  1674.         keyword    Watch,WATCH
  1675.         keyword Watch,SNOOP ; synonym for WATCH
  1676.         keyword    Hide,HIDE
  1677.         keyword    Pri,PRI
  1678.         keyword    Show,SHOW
  1679.         keyword    Define,DEFINE
  1680.         keyword    Bitdef,BITDEF
  1681.         keyword    Include,INCLUDE
  1682.         keyword    Incdir,INCDIR
  1683.         keyword    Output,OUTPUT
  1684.         keyword    Sticky,STICKY
  1685.         keyword    Match,MATCH
  1686.         keyword    TaskInfo,TASKINFO
  1687.         keyword    SegTracker,SEGTRACKER
  1688.         keyword    Alias,ALIAS
  1689.         keyword    Assume,ASSUME
  1690.         keyword    Echo,ECHO
  1691.         keyword    Echo,PRINT
  1692.         keyword    Device,DEVICE
  1693.         keyword    DevCmd,DEVCMD
  1694.         keyword    BeginIO,BEGINIO
  1695.         keyword    AbortIO,ABORTIO
  1696.         keyword    Resource,RESOURCE
  1697.         keyword    SkipSimilar,SKIPSIMILAR
  1698.         keyword    Timeout,DELAY
  1699.  
  1700. ;--------------    structure macros
  1701.         keyword    Structure,STRUCTURE
  1702.         keyword    LONG,APTR
  1703.         keyword    LONG,CPTR
  1704.         keyword    LONG,FPTR
  1705.         keyword    LONG,LONG
  1706.         keyword    LONG,ULONG
  1707.         keyword    LONG,FLOAT
  1708.         keyword    WORD,BOOL
  1709.         keyword    WORD,RPTR
  1710.         keyword    WORD,WORD
  1711.         keyword    WORD,UWORD
  1712.         keyword    WORD,SHORT
  1713.         keyword    WORD,USHORT
  1714.         keyword    BYTE,BYTE
  1715.         keyword    BYTE,UBYTE
  1716.         keyword    LABEL,LABEL
  1717.         keyword    STRUCT,STRUCT
  1718.         keyword    ALIGNWORD,ALIGNWORD
  1719.         keyword    ALIGNLONG,ALIGNLONG
  1720.  
  1721. ;--------------    the following options are not documented (yet); they will be fully
  1722. ;--------------    introduced in the next versions (guess what they are about)
  1723.         keyword    SkipSegNotFound,SKIPSEGNOTFOUND
  1724.         keyword    DONE
  1725.  
  1726. BoolKeys    dc.w    .1-BoolKeys,TRUE
  1727.         dc.w    .2-BoolKeys,TRUE
  1728.         dc.w    .3-BoolKeys,TRUE
  1729.         dc.w    .4-BoolKeys,TRUE
  1730.         dc.w    .5-BoolKeys,FALSE
  1731.         dc.w    .6-BoolKeys,FALSE
  1732.         dc.w    .7-BoolKeys,FALSE
  1733.         dc.w    .8-BoolKeys,FALSE
  1734.         dc.w    .9-BoolKeys,TRUE
  1735.         dc.w    .10-BoolKeys,FALSE
  1736.         dc.w    0
  1737. .1        cstr    "YES"
  1738. .2        cstr    "TRUE"
  1739. .3        cstr    "ON"
  1740. .4        cstr    "ACTIVE"
  1741. .5        cstr    "NO"
  1742. .6        cstr    "FALSE"
  1743. .7        cstr    "OFF"
  1744. .8        cstr    "NOT ACTIVE"
  1745. ;--------------    hey! you found out about these! Don't tell everybody! ;-)
  1746. .9        cstr    "FUNKY"
  1747. .10        cstr    "SHIT"
  1748.         even
  1749.  
  1750. AssumeKeys    dc.w    .1-AssumeKeys,ASSUME_LONG
  1751.         dc.w    .2-AssumeKeys,ASSUME_WORD
  1752.         dc.w    .3-AssumeKeys,ASSUME_BYTE
  1753.         dc.w    0
  1754. .1        cstr    "LONG"
  1755. .2        cstr    "WORD"
  1756. .3        cstr    "BYTE"
  1757.         even
  1758.  
  1759. memoryError    DEFINE_ALERT <FATAL ERROR, not enough memory available>
  1760.  
  1761. insertdecFormat    cstr    '%ld'
  1762. inserthexFormat    cstr    '%lx'
  1763. openfileErr    cstr    'ERROR, cannot open scriptfile "%s"'
  1764.  
  1765. ;--------------    error strings supported by this module
  1766. errorHeader    cstr    'ERROR in line %ld: "%s"\n'
  1767. invalidlineErr    cstr    '%sunknown commands or invalid input line\n'
  1768. openlibErr    cstr    '%scannot open library "%s"'
  1769. openresErr    cstr    '%scannot open resource "%s"'
  1770. opendevErr    cstr    '%scannot open device "%s"'
  1771. basesizeErr    cstr    '%sbase shortcut too long (max=',_VALOF(MAX_BASENAME),')'
  1772. defsizeErr    cstr    '%sdefine name too long (max=',_VALOF(MAX_DEFINENAME),')'
  1773. inclevelErr    cstr    '%sinclude level overflow (max=',_VALOF(MAX_INCLUDELEVEL),')'
  1774. openincErr    cstr    '%scannot open includefile "%s"'
  1775. incdirsizeErr    cstr    '%sincdir name too long (max=',_VALOF(MAX_INCDIRNAME),')'
  1776. tasksizeErr    cstr    '%staskname too long (max=',_VALOF(MAX_TASKNAME),')'
  1777. invalidboolErr    cstr    '%sinvalid boolean expression "%s"'
  1778. aliasnameErr    cstr    '%salias name too long (max=',_VALOF(MAX_ALIASNAME),')'
  1779. aliascontentErr    cstr    '%salias contents too long (max=',_VALOF(MAX_ALIASCONTENTS),')'
  1780. invassumeErr    cstr    '%sinvalid assumption "%s"'
  1781. tempsizeErr    cstr    '%stemplate too long (max=',_VALOF(MAX_TEMPLATE),')'
  1782. nobaseErr    cstr    '%scannot find library base for this definition'
  1783. nodevbaseErr    cstr    '%scannot find device base for this definition'
  1784. nooffsetErr    cstr    '%soffset "%s" not defined'
  1785. argsizeErr    cstr    '%stoo many output arguments (max=',_VALOF(MAX_ARGUMENTS),')'
  1786. msgportErr    cstr    '%scannot allocate message port'
  1787.  
  1788.         section    memory,bss
  1789.  
  1790. currentLine    ds.l    1
  1791.         defs.l    outputArgs,256
  1792.         defs.b    inputMemory,<(MAX_INPUT+2)>
  1793. input        ds.b    MAX_INPUT+2
  1794.         defs.b    outputMemory,MAX_INPUT+2
  1795. incdirBuffer    ds.b    MAX_INCDIRNAME
  1796. includeName    ds.b    MAX_INCDIRNAME
  1797. includeLevel    ds.b    1
  1798. assume        ds.b    1
  1799.         even
  1800. errorBuffer    ds.b    MAX_INPUT+80
  1801.         defs.l    flagSegTracker,1
  1802.         defs.l    flagSkipSimilar,1
  1803.         defs.l    flagSkipSegNotFound,1
  1804.         defs.l    timeout,1
  1805.         defs.l    priority,1
  1806.         defs.l    structureOffset,1
  1807.  
  1808.         end
  1809.  
  1810. ;--------------    ecstasy mutherfuckers! the future is before your eyes!
  1811.  
  1812. **************************************************************************
  1813. ;--------------    
  1814.